#include "Scene.h"

#include "Camera.h"
#include "Light.h"
#include "Object.h"

using namespace std;


Scene::Scene() :
    m_camera(NULL)
{
}

void Scene::addObject(Object *obj)
{
    m_objects.push_back(obj);
}

void Scene::addLight(Light *light)
{
    m_lights.push_back(light);
}

void Scene::setCamera(Camera *camera)
{
    m_camera = camera;
}

void Scene::removeObject(Object *obj)
{
    m_objects.remove(obj);
}

void Scene::removeLight(Light *light)
{
    m_lights.remove(light);
}

Camera *Scene::getCamera()
{
    return m_camera;
}

list<Object*> Scene::getObjects()
{
    return m_objects;
}

list<Light*> Scene::getLights()
{
    return m_lights;
}

void Scene::draw()
{
    m_camera->applyModelView();

    for (list<Light*>::iterator it = m_lights.begin(); it != m_lights.end(); ++it)
    {
        (*it)->applyGL();
    }

    for (list<Object*>::iterator it = m_objects.begin(); it != m_objects.end(); ++it)
    {
        (*it)->draw();
    }
}
